package com.aaa.order.factory;

import com.aaa.entity.Product;
import com.aaa.order.feign.ProductFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @program: qy156-shop-parent
 * @description:
 * @author: 闫克起2
 * @create: 2022-11-25 15:48
 **/
@Component
@Slf4j
public class ProductFeignFactory implements FallbackFactory<ProductFeign>{
    @Override
    public ProductFeign create(Throwable throwable) {
        return new ProductFeign() {
            @Override
            public Product getById(Long pid) {
                log.error("商品微服务故障"+throwable.getMessage());
                //默认的一个商品对象
                Product product=new Product();
                return product;
            }
        };
    }
}
